package com.ego.controller;

import com.ego.commons.pojo.EgoResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PageController {

    //登录页面
    @GetMapping("/")
    public String login(){
        System.out.println("跳转登录页面控制器");
        return "login";
    }

    //后台首页
    @GetMapping("/main")
    public String index(){
        return "index";
    }

    /**
     * 登录成功跳转页面
     * @return
     */
    @RequestMapping("/loginSuccession")
    @ResponseBody
    public EgoResult loginSuccess(){
        return EgoResult.ok();
    }


    // http://localhost/item-add
    // http://localhost/item-list
    @RequestMapping("/{page}")
    public String showPage(@PathVariable("page")String page){
        return page;
    }



    //跳转到编辑（修改）页面
    @RequestMapping("/rest/page/item-edit")
    public String  itemEdit(){
        return "item-edit";
    }
}
